import pandas as pd
import jieba
import jieba.posseg as pseg
jieba.enable_paddle()


def get_loc(text):
    loc_list = []  # 人名列表
    word_list = jieba.lcut(text)
    # print(word_list)
    for word in word_list:
        if len(word)==1:  # 不加判断会爆
            continue
        words = pseg.cut(word, use_paddle=True)  # paddle模式
        # print(list(words))
        word, flag = list(words)[0]
        if flag=='LOC':  # 这里写成LOC是地名
            loc_list.append(word)
    loc_list = list(set(loc_list))
    # print(per_list)
    if '河南' in loc_list: loc_list.remove('河南')
    if '河南省' in loc_list: loc_list.remove('河南省')   
    return loc_list
if __name__=='__main__':
    text = '项目位于河南省荥阳市'
    loc_list = get_loc(text)
    print(loc_list)
